package com.creawor.hz_market.resource.cheliang_resource;

import java.util.Date;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Hibernate;
import net.sf.hibernate.LockMode;
//import oracle.sql.CLOB;
import com.creawor.imei.base.AbsEditMap;

public class CheliangResource_EditMap extends AbsEditMap {

public void add(CheliangResource_Form vo) throws HibernateException {
	CheliangResource po=new CheliangResource();
try{
  po.setId(java.lang.Integer.parseInt(vo.getId()));
}catch (Exception e) {
 e.printStackTrace();
}

try{
 po.setCounty(vo.getCounty());
}catch (Exception e) {
 e.printStackTrace();
}
try{
	  po.setSelfNum(java.lang.Integer.parseInt(vo.getSelfNum()));
	}catch (Exception e) {
	 e.printStackTrace();
	}
try{
	  po.setZuyongNum(java.lang.Integer.parseInt(vo.getZuyongNum()));
	}catch (Exception e) {
	 e.printStackTrace();
	}

try{
	    po.setInsertDay(com.creawor.km.util.DateUtil.getDate(vo.getInsertDay(),"yyyy-MM-dd"));
	 }catch (Exception e) {
	   e.printStackTrace();
	  }
	 try{
	   po.setUpdatedDay(com.creawor.km.util.DateUtil.getDate(vo.getUpdatedDay(),"yyyy-MM-dd"));
	//   po.setUpdated_day(new Date());
	  }catch (Exception e) {
	   e.printStackTrace();
	  }

		Session session = this.beginTransaction();
try {
	session.save(po);

	this.endTransaction(true);
} catch (Exception e) {
	this.endTransaction(false);
	e.printStackTrace();
 throw new HibernateException(e);}	
}

public void delete(CheliangResource_Form vo) throws HibernateException {
String id = vo.getId();
delete(id);
}

public void delete(String id) throws HibernateException {
Session session = this.beginTransaction();
try{
	CheliangResource po =(CheliangResource) session.load(CheliangResource.class, new Integer(id));
session.delete(po);
this.endTransaction(true);
} catch (HibernateException e) {
e.printStackTrace();
this.endTransaction(false);
}
}

public void update(CheliangResource_Form vo) throws HibernateException {
	Session session = this.beginTransaction();
 String id = vo.getId();
 CheliangResource po =(CheliangResource) session.load(CheliangResource.class, new Integer(id));
try{
  po.setId(java.lang.Integer.parseInt(vo.getId()));
}catch (Exception e) {
 e.printStackTrace();
}

try{
	 po.setCounty(vo.getCounty());
	}catch (Exception e) {
	 e.printStackTrace();
	}
try{
	  po.setSelfNum(java.lang.Integer.parseInt(vo.getSelfNum()));
	}catch (Exception e) {
	 e.printStackTrace();
	}
try{
	  po.setZuyongNum(java.lang.Integer.parseInt(vo.getZuyongNum()));
	}catch (Exception e) {
	 e.printStackTrace();
	}
try{
	    po.setInsertDay(com.creawor.km.util.DateUtil.getDate(vo.getInsertDay(),"yyyy-MM-dd"));
	 }catch (Exception e) {
	   e.printStackTrace();
	  }
 try{
   po.setUpdatedDay(com.creawor.km.util.DateUtil.getDate(vo.getUpdatedDay(),"yyyy-MM-dd"));
//   po.setUpdated_day(new Date());
  }catch (Exception e) {
   e.printStackTrace();
  }
try {
	session.update(po);

	this.endTransaction(true);
} catch (Exception e) {
	this.endTransaction(false);
	e.printStackTrace();
 throw new HibernateException(e);  }
}
}
//����������

